package com.ease;

public class Nine_RetureText {

    public static void main(String[] args) {

        Nine_RetureText s1=new Nine_RetureText();
        boolean palindrome = s1.isPalindrome(
                123321);
        System.out.println(palindrome);

    }
    public boolean isPalindrome(int x) {
//        if (x < 0) {
//            return false;
//        }
//        int num = x;
//        int length = 0;
//
//        while (num != 0) {
//            num /= 10;
//            length++;
//        }
        String str = String.valueOf(x);
        int length=str.length();


        char[] arr1 = new char[length];
        char[] arr2 = new char[length];

        for (int i = 0; i < length; i++) {
            arr1[i] =str.charAt(i);
        }

        for (int i = 0; i < length; i++) {
            arr2[i] = arr1[length - 1 - i];
        }

        for (int i = 0; i < length; i++) {
            if (arr1[i] != arr2[i]) {
                return false;
            }
        }

        return true;
    }




//    public boolean isPalindrome(int x) {
//        String str = String.valueOf(x);
//        int left = 0;
//        int right = str.length() - 1;
//
//        while (left < right) {
//            if (str.charAt(left) != str.charAt(right)) {
//                return false;
//            }
//            left++;
//            right--;
//        }
//        return true;
//    }

}
